package cn.yzfy.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serial;

/**
 * @author 一朝风月
 * @date 2025/9/11 13:57
 * @Code 面向注解面向卿，终无解释再无你
 * @description
 */
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@Data
public class BaseException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 5198832777383506332L;

    private int code;

    public BaseException(int code) {
        this.code = code;
    }

    public BaseException(String message, int code) {
        super(message);
        this.code = code;
    }

    public BaseException(String message, Throwable cause, int code) {
        super(message, cause);
        this.code = code;
    }

    public BaseException(Throwable cause, int code) {
        super(cause);
        this.code = code;
    }

    public BaseException(String message, Throwable cause, boolean enableSuppression,
                         boolean writableStackTrace, int code) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
